// pages/components/cancle_orde/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean,
      value: ''
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    reasonList: [{
        name: '不想买了',
        checked: false
      },
      // {
      //   name: '送达时间超时了',
      //   checked: false
      // },
      {
        name: '忘记选择优惠券',
        checked: false
      },
      {
        name: '商品选多了/选错了/选漏了',
        checked: false
      },
      {
        name: '地址选错了',
        checked: false
      },
      {
        name: '其他',
        checked: false
      },
    ],
    explain:''
  },
  ready() {

  },
  /**
   * 组件的方法列表
   */
  methods: {
    closeReason() {
      this.triggerEvent('close')
    },
    sendUp() {
      this.triggerEvent('send',this.data.explain)
    },
    checkboxChange(e) {
      let index = e.currentTarget.dataset.index
      let reasonList = this.data.reasonList
      let explain = this.data.explain
      reasonList[index].checked = !reasonList[index].checked
      
      reasonList.forEach(function (o, i) {
        if (i != index) {
          o.checked = false
        }
      })
      this.setData({
        reasonList,
        explain:reasonList[index].name
      })
    }
  }
})